package com.leetcode.August;

/**
 * @Description: 219. 存在重复元素 II
 * @Author: Mr.Fxy
 * @CreateTime: 2024-09-15 20:32
 */
public class LC219存在重复元素II {
    public boolean containsNearbyDuplicate(int[] nums, int k) {
        if (nums.length == 0) return false;
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] == nums[j] && Math.abs(i - j) <= k) {
                    return true;
                }
            }
        }
        return false;
    }
}
